﻿<!DOCTYPE html>

<html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>

<body>
    <div class="framecontainer">
        <div class="leftcontinaer">
            <div class="cloud-panel">
                <div class="cloud-panel-header ">
                    <div class="cloud-panel-title">模块列表</div>
                </div>
                <div class="cloud-panel-body">
                    <ul id="tree" class="ztree" overflow:auto;"></ul>
                </div>
            </div>
        </div>
        <div class="rightcontinaer">
            <div class="cloud-panel">
                <div class="cloud-panel-header ">
                    <div class="cloud-panel-title">模块管理</div>
                </div>
                <div class="cloud-panel-body">
                    <div class="searchop">
                        <div class="btnop">
                            <button class="btn btn-op" type="button" onclick="OpenAdd()"><span class="btntext">新增模块</span></button>
                            <button class="btn btn-op" type="button" onclick="BatchDelete()"><span class="btntext">批量删除</span></button>
                        </div>
                        <div class="btnop">
                            <input id="ModuleName" type="text" class="form-control searchinput" placeholder="请输入模块名称">
                            <div class="checkbox-primary" style="margin-top:5px;margin-left:5px;margin-right:10px"><input type="checkbox" id="SearchInAll"><label for="SearchInAll">所有模块</label></div>
                            <button class="btn" type="button" onclick="BindGrid()"><i class="icon icon-search"></i><span class="searchtext">搜索</span></button>
                        </div>
                    </div>
                    <div class="tableop">
                        <table class="GridStyle" id="CloudGrid" keyid="ModuleGuid" url="oplist" relationpageid="cloudpagination" otherparm="SearchParm" afterbind="AfterBindData">
                            <tr class="HeaderStyle">
                                <th scope="col" style="width: 10px;" field="check" rowalign="center"></th>
                                <th scope="col" style="width: 10px;" field="index" rowalign="center">序</th>
                                <th scope="col" field="ModuleName" rowalign="left" style="width:150px">模块名称</th>
                                <th scope="col" field="ModuleUrl" rowalign="left">模块地址</th>
                                <th scope="col" style="width: 50px;" field="SortNum" rowalign="center">排序</th>
                                <th scope="col" style="width: 50px;" field="EditButton" functionname="GridEdit" rowalign="center">详细</th>
                            </tr>
                        </table>
                    </div>
                    <div class="bottomop">
                        <div class="pageop">
                            <ul class="pagination" id="cloudpagination"></ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var ParentModuleGuid = "Top"
        $(function () {
            RefreshPage();
            $("#SearchInAll").change(function () {
                BindGrid();
            })
        })
        function BindGrid() {
            BindCloudGrid($("#CloudGrid"))
        }
        function BindTree() {
            CloudPost({}, "tree", function (res) {
                BindMenuTree("tree", res.data, TreeNodeOnClick);
            })
        }
        function SearchParm() {
            return {
                "ModuleName": $("#ModuleName").val(),
                "ParentModuleGuid": ParentModuleGuid,
                "SearchInAll":$('#SearchInAll').is(':checked')
            };
        }
        function AfterBindData() {

        }
        function OpenAdd() {
            OpenTopDialog("新增模块", "frame/org/module/add?parentmoduleguid=" + ParentModuleGuid, 600, 800, RefreshPage)
        }
        function BatchDelete() {
            var SelectRows = CloudGridChecked($("#CloudGrid"));
            if (SelectRows.length > 0) {
                OpenConfirm("确认删除选中的数据？", function () {
                    CloudPost({ "KeyID": SelectRows }, "opbatchdelete", function (res) {
                        if (res.code == 0) {
                            OpenSuccess("删除成功！", function () {
                                RefreshPage();
                            })
                        } else {
                            OpenFail(res.data);
                        }
                    })
                })
            }
        }
        function GridEdit(RowData) {
            OpenTopDialog("编辑", "frame/org/module/edit?moduleguid=" + RowData.ModuleGuid, 600, 800, RefreshPage)
        }
        function RefreshPage() {
            BindGrid();
            BindTree();
        }
        function TreeNodeOnClick(event, treeId, treeNode, clickFlag) {
            ParentModuleGuid = treeNode.id
            BindGrid();
        }
    </script>
</body>
</html>